home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 29
/
Volume 29 - JOGO DISK .iso
/
Games
/
jungle_adventure.swf
/
scripts
/
__Packages
/
GameViewport.as
< prev
next >
Wrap
Text File
|
2006-11-29
|
2KB
|
71 lines
class GameViewport extends SSViewport
{
var stallTime = 0;
var lockPos = false;
var response = 1.7;
var xLead = 0.4;
var shake = 0;
var strength = 2;
var lastShake = 0;
var locked = false;
function GameViewport()
{
super();
}
function stall(time)
{
this.stallTime = time;
}
function shakeCamera(time, amount)
{
this.shake = time;
this.strength = amount;
this.lastShake = 0;
}
function lock()
{
this.locked = true;
}
function unlock()
{
this.locked = false;
}
function update(elapsed)
{
if(!this.watch)
{
return undefined;
}
if(this.stallTime)
{
this.stallTime = Math.max(0,this.stallTime - elapsed);
}
else if(this.watch.finished)
{
this.moveTo(Math.round(this.x + (this.watch.x - this.x) * elapsed * 4),Math.round(this.y + (this.watch.y - this.y - 100) * elapsed * 4),this.focusDepth);
}
else if(!this.locked)
{
if(this.watch.swinging)
{
var _loc3_ = 0;
this.tx = this.watch.x + (this.watch.dispAxis * this.halfWidth * this.xLead + this.watch.velocity.x) / 4;
this.ty = this.watch.y + (_loc3_ + this.watch.velocity.y) / 4;
}
else
{
_loc3_ = !(this.watch.jumpTime || !this.watch.inMotion) ? Math.min(Math.max(this.watch.velocity.y * 0.5,-150),150) : this.watch.contactNormal.y * this.halfHeight * 0.2 + this.watch.dispAxis * this.watch.contactNormal.x * this.halfHeight * 0.7;
this.tx = this.watch.x + (this.watch.dispAxis * this.halfWidth * this.xLead + this.watch.velocity.x) / this.response;
this.ty = this.watch.y + (_loc3_ + this.watch.velocity.y) / this.response;
}
this.moveTo(Math.round((this.x + (this.tx - this.x) * elapsed * this.response) * 4) / 4,Math.round((this.y + (this.ty - this.y) * elapsed * this.response) * 4) / 4,this.focusDepth);
}
if(this.shake)
{
this.shake = Math.max(0,this.shake - elapsed);
this.lastShake += 1;
this.moveBy(0,(this.lastShake % 2 != 1 ? 1 : -1) * this.strength,0);
}
}
}